﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TextTemplating.VSHost;
using System.IO;

namespace DSLFactory.VSCTDesigner
{
    [System.Runtime.InteropServices.Guid("D2888614-5E5A-4ae9-A601-C7E811563BF6")]
    class CodeGenerator : TemplatedCodeGenerator
    {
        protected override byte[] GenerateCode(string inputFileName, string inputFileContent)
        {
            // Replace the supplied file contents with the template we want to run 
            inputFileContent = ASCIIEncoding.UTF8.GetString(DSLFactory.VSCTDesigner.Properties.Resources.VSCTCommandSet);

            // Now just delegate the rest of the work to the base class
            byte[] data;
            data = base.GenerateCode(inputFileName, inputFileContent);
            byte[] ascii = new byte[data.Length - 3];
            Array.Copy(data, 3, ascii, 0, data.Length - 3);
            return ascii;

        }
    }
}
